package com.code.algorithn;

import java.util.LinkedList;
import java.util.Queue;

public class TestSequeue {

	private int[] numbers = { 6, 3, 1, 7, 5, 8, 9, 2, 4 };

	public void testAlgorithn() {

		Queue sequeue = new LinkedList();

		for (int number : numbers) {
			sequeue.add(number);
		}

		Queue sequeue2 = new LinkedList();

		while (!sequeue.isEmpty()) {
			try {
				// 处理第一个
				sequeue2.add(sequeue.remove());

				sequeue.add(sequeue.remove());

			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		while (!sequeue2.isEmpty()) {
			System.out.println(sequeue2.remove());
		}

	}

	public static void main(String[] args) {
		TestSequeue ts = new TestSequeue();
		ts.testAlgorithn();
	}

}
